/*
 * Copyright (c) 2020, 2023, keyila All rights reserved.
 *
 */
package com.clp.study.designPattern.abstractFactoryPattern.easy;

/**
 * @author clp
 * @version 1.0
 */
public class AbstractFactoryPatternDemo {
    public static void main(String[] args) {
        //获取形状工厂
        AbstractFactory shapeFactory = FactoryProducer.getFactory("SHAPE");
        //获取性状为 Circle的对象
        Shape circle = shapeFactory.getShape("CIRCLE");
        //调用Circle的draw方法
        circle.draw();
        //获取性状为 RECTANGLE的对象
        Shape rectangle = shapeFactory.getShape("RECTANGLE");
        //调用rectangle的draw方法
        rectangle.draw();
        //获取性状为 Circle的对象
        Shape square = shapeFactory.getShape("SQUARE");
        //调用square的draw方法
        square.draw();
        System.out.println("**********");
        //获取颜色工厂
        AbstractFactory colorFactory = FactoryProducer.getFactory("COLOR");
        //获取颜色为RED的对象
        Color red = colorFactory.getColor("RED");
        //调用red的fill方法
        red.fill();
        //获取颜色为GREEN的对象
        Color green = colorFactory.getColor("GREEN");
        //调用green的fill方法
        green.fill();
        //获取颜色为BLUE的对象
        Color blue = colorFactory.getColor("BLUE");
        //调用blue的fill方法
        blue.fill();
    }
}
